/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package game.chips;

import game.Player;
import game.chips.Chip;

import java.util.Random;
import java.util.concurrent.atomic.AtomicIntegerArray;


public class WhiteChip extends Chip {

    public WhiteChip(Player owner) {
        super(owner);
    }
    
    public void run() {
        while(!getOut()) {
            if (getTurn())
                turn();
            else 
                try {
                Thread.sleep(5);
            } catch (InterruptedException ex) {
                    //System.out.println("Sleep problem in WhiteChip");
            }
        }
    }
    
    public void turn() {
        AtomicIntegerArray new_coord = new AtomicIntegerArray(2);
        
        new_coord.set(0, getState().get(0));
        new_coord.set(1, getState().get(1) + new Random().nextInt(2) + 1);
        
        
        setAfterTurn(new_coord);
        setTurn();
    }
    
    public String toString() {
        return ("White");
    }
}
